//index.js
//获取应用实例
const app = getApp();
import {
  getIndexData
} from '../../api/api.js';
Page({
  data: {
    parameter: {
      'navbar': '0',
      'return': '0'
    },
    logoUrl: "https://shop-product-image.oss-cn-shenzhen.aliyuncs.com/logo.jpg",
    navH: "",
    imgUrls: [
    {
        "id": 104,
        "name": "banenr2",
        "url": "/pages/pink-list/index?id=2",
        "pic": "https://shop-product-image.oss-cn-shenzhen.aliyuncs.com/u%3D1033807060%2C900938978%26fm%3D26%26gp%3D0.jpg"
      },{
        "id": 104,
        "name": "banenr2",
        "url": "/pages/pink-list/index?id=2",
        "pic": "https://shop-product-image.oss-cn-shenzhen.aliyuncs.com/u%3D3015336439%2C1716148804%26fm%3D26%26gp%3D0.jpg"
      },{
        "id": 104,
        "name": "banenr2",
        "url": "/pages/pink-list/index?id=2",
        "pic": "https://shop-product-image.oss-cn-shenzhen.aliyuncs.com/u%3D3664004135%2C2710504387%26fm%3D26%26gp%3D0.jpg"
      },{
        "id": 104,
        "name": "banenr2",
        "url": "/pages/pink-list/index?id=2",
        "pic": "https://shop-product-image.oss-cn-shenzhen.aliyuncs.com/u%3D997264476%2C3129601306%26fm%3D11%26gp%3D0.jpg"
      }],
    itemNew: [{
        "id": 122,
        "info": "三鲜商城即将上线，请期待！",
        "url": "/packageB/news_list/index",
        "show": "2",
        "wap_url": "/news_list"
      },
      {
        "id": 123,
        "info": "海贼王ALL BLUE的新鲜食材！",
        "url": "/packageB/news_list/index",
        "show": "2",
        "wap_url": "/news_list"
      }],
    bestList: [],
    hotList: [],
    indicatorDots: false,
    circular: true,
    autoplay: true,
    interval: 3000,
    duration: 500,
    iShidden: false,
  },
  onLoad: function() {
    this.setData({
      navH: app.globalData.navHeight
    });
    if (wx.getStorageSync('msg_key')) this.setData({
      iShidden: true
    });
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.getIndexData();
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {
    this.getIndexConfig();    
    wx.stopPullDownRefresh();
  },
  closeTip: function() {
    wx.setStorageSync('msg_key', true);
    this.setData({
      iShidden: true
    })
  },
  catchTouchMove: function(res) {
    return false
  },
  getIndexData: function() {
    var that = this;
    getIndexData().then(res => {
      that.setData({
        imgUrls: res.data.banner,
        itemNew: res.data.itemNews,
        bestList: res.data.bestProducts,
        hotList: res.data.hotProducts
      });
    }).catch(err => {
      app.Tips({
        title: err
      })
    })
  }
})